package mh.modules.sys.service.impl;

import mh.common.utils.R;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import mh.common.utils.PageUtils;
import mh.common.utils.Query;

import mh.modules.sys.dao.NoticesDao;
import mh.modules.sys.entity.NoticesEntity;
import mh.modules.sys.service.NoticesService;


@Service("noticesService")
public class NoticesServiceImpl extends ServiceImpl<NoticesDao, NoticesEntity> implements NoticesService {

    @Autowired
    private  NoticesDao noticesDao;
    @Autowired
    private NoticesService noticesService;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<NoticesEntity> page = this.page(
                new Query<NoticesEntity>().getPage(params),
                new QueryWrapper<NoticesEntity>().like(StringUtils.isNotBlank((String) params.get("key")),"author",params.get("key"))
        );

        return new PageUtils(page);
    }

    @Override
    public R isActive() {
        List<NoticesEntity> entityList = noticesDao.getIsActive();
//        System.out.println("发布的内容"+entityList);
        R r = new R();
        r.put("data",entityList);
        return r;
    }

}